<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户信息(按kkuid分区)列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>手机：</p>
                                <input type="text" name="phone"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('user:kkuserInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('user:kkuserInfo:remove')}]];
        var appIdDatas = [[${@dict.getType('storage_app_type')}]];
        var prefix = ctx + "user/kkuserInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户信息(按kkuid分区)",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'appId',
                    title : '应用',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(appIdDatas, value);
                    }
                },
                {
                    field : 'nickname',
                    title : '昵称'
                },
                {
                    field : 'createdTime',
                    title : '注册时间'
                },
                {
                    field : 'kkid',
                    title : 'kkid'
                },
                {
                    field : 'kkNumber',
                    title : 'k号'
                },
                {
                    field : 'cancel',
                    title : '状态',
                    formatter: function(value, row, index) {
                       if(value == 1){
                         return "<font color='red'>注销</font>";
                       }else{
                         return "<font color='green'>正常</font>";
                       }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.cancel == 1){
                           actions.push(`<a class="btn btn-danger btn-xs ${removeFlag}" href="javascript:void(0)" onclick="reuse('${row.appId}', '${row.userId}')"><i class="fa fa-remove"></i>恢复帐号</a>`);
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function reuse(appId, userId) {
			$.modal.confirm("确定要恢复该帐号吗?", function() {
				$.operate.post(prefix + "/reuse", { "appId": appId, "userId": userId });
		    })
		}

    </script>
</body>
</html>